﻿import com.gamepackage.events.*;
import com.gamepackage.util.LoadClip;

class Preloader extends MovieClip
{
	private var display: TextField;
	private var bytes: TextField;
	
	function onLoad(): Void
	{
		this.stop();
		display.text = 'request swfs...';
	}
	
	function onLoadClipProcess( lc: LoadClip, loadedBytes: Number, totalBytes: Number ): Void
	{
		this.gotoAndStop( int( loadedBytes / totalBytes * 100 ) + 1 );
	}
	
	function onLoadQueueComplete( Void ): Void
	{
		display.text = "loading complete.";
		
		new Timeout( new Call( this , removeMovieClip ) , 30 );
	}
	
	function onLoadClipFailed( lc: LoadClip ): Void
	{
		display.text = "loading failed " + lc.getInfo().name;
	}
	
	function onLoadClipRequest( lc: LoadClip, totalBytes: Number ): Void
	{
		display.text = 'request: ' + lc.getInfo().name;
	}
	
	function onLoadClipStart( lc: LoadClip, totalBytes: Number ): Void
	{
		display.text = 'loading: ' + lc.getInfo().name + "\t" + int( totalBytes / 100 ) / 10 + " kb.";
	}
}